package com.mosai.alignpro.view;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import androidx.annotation.NonNull;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.mosai.alignpro.R;

/**
 * Created by Rays on 2020/9/25.
 */
public class NoPatientDialog extends Dialog implements View.OnClickListener {

    private OnClickListener onClickListener;

    public NoPatientDialog(@NonNull Context context, OnClickListener onClickListener) {
        super(context, R.style.LoadingDialog);
        setContentView(R.layout.no_patient_loading);
        this.onClickListener = onClickListener;
        findViewById(R.id.tvCancel).setOnClickListener(this);
        findViewById(R.id.llConfirm).setOnClickListener(this);
        findViewById(R.id.tvBind).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.tvCancel) {
            if (onClickListener != null) {
                onClickListener.onClick(this, DialogInterface.BUTTON_NEGATIVE);
            }
        } else if (v.getId() == R.id.tvBind) {
            if (onClickListener != null) {
                onClickListener.onClick(this, DialogInterface.BUTTON_NEUTRAL);
            }
        } else if (v.getId() == R.id.llConfirm) {
            if (onClickListener != null) {
                onClickListener.onClick(this, DialogInterface.BUTTON_POSITIVE);
            }
        }
    }

    @Override
    public void show() {
        super.show();
        Window window = getWindow();
        if (window == null) {
            return;
        }
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(layoutParams);
    }
}
